package cn.itcast.web.conver;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/*
日期转化器
     实现Converter接口
 */
public class StringToDate implements Converter<String, Date> {
    @Override
    public Date convert(String s) {
        Date result=null;
        try {
            result=new SimpleDateFormat("yyyy-MM-dd").parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return result;
    }
}
